let isDev = process.env.NODE_ENV === "development";

const USER_INFO = isDev ? "user_info_obj_dev" : "user_info_obj";
const XY_AGREE = isDev ? "xy_agree_dev" : "xy_agree";
const TOKEN = isDev ? "token_dev" : "token";
const CURRENT_DEVICE = isDev ? "current_device_dev" : "current_device";

export default {
	// 写入用户协议是否同意
	setXyAgree(val) {
		uni.setStorageSync(XY_AGREE, val);
	},
	// 获取用户协议是否同意
	getXyAgree() {
		return uni.getStorageSync(XY_AGREE);
	},
	// 移除用户协议是否同意
	removeXyAgree() {
		return uni.removeStorageSync(XY_AGREE);
	},
	// 写入用户协议是否同意
	setToken(val) {
		if (!val || val == 'null') {} else {
			uni.setStorageSync(TOKEN, val);
		}
	},
	// 获取用户协议是否同意
	getToken() {
		return uni.getStorageSync(TOKEN);
	},
	// 移除用户协议是否同意
	removeToken() {
		return uni.removeStorageSync(TOKEN);
	},
	// 写入用户信息
	setUserInfo(val) {
		uni.setStorageSync(USER_INFO, val);
	},
	// 获取用户信息
	getUserInfo() {
		return uni.getStorageSync(USER_INFO);
	},
	// 移除用户信息
	removeUserInfo() {
		return uni.removeStorageSync(USER_INFO);
	},
	// 写入当前设备
	setCurrentDevice(val) {
		console.log('*setCurrentDevice*', val)
		uni.setStorageSync(CURRENT_DEVICE, val);
	},
	// 获取当前设备
	getCurrentDevice() {
		console.log('*getCurrentDevice*', uni.getStorageSync(CURRENT_DEVICE))
		return uni.getStorageSync(CURRENT_DEVICE);
	},
	// 移除当前设备
	removeCurrentDevice() {
		return uni.removeStorageSync(CURRENT_DEVICE);
	}
};
